E. Nordmoe
E. Nordmoe
mtcarsmtcars==> See R4DS for more details!
Step 1: Create the Function
Step 2: Apply the function by looping
col_mean() and col_median() functions.mtcarsmap() ==> listmap_lgl() ==> logical vectormap_dbl() ==> double vectormtcarsmap_df to create a data frame by binding rows
## Mapping over two arguments: `map2()`
```r
# mu and sigma are the arguments
# rnorm is the function
mu = list(5, 10, -3)
sigma = list(1, 5, 10)
map2(mu, sigma, rnorm, n = 5)
pmap()fun <- function(f) pmap(list(x = mtcars, na.rm = TRUE), f)
param <- list(list(mean), list(median), list(sd))
invoke_map(.f = fun, .x = param)invoke_map() level, fun takes as arguments param, which are the functions we want to apply to mtcars.fun level, these functions stored in param are applied by pmap(), one at a time, to each column in mtcars.